//FIXME: date-picker、time-picker、radio、radio-group使用时会样式丢失，需要手动引入
import FormInput from './components/input'
import FormAvatar from './components/avatar'
import FormDatePicker from './components/date-picker'
import FormInputNumber from './components/input-number'
import FormSlider from './components/slider'
import FormSwitch from './components/switch'
import FormTimePicker from './components/time-picker'
import FormTimeSelect from './components/time-select'
import FormTransfer from './components/transfer'
import FormTree from './components/tree'
import FormUpload from './components/upload'
import FormSelect from './components/select'
import FormRadio from './components/radio'
import FormCheckbox from './components/checkbox'

const componentMap = new Map()
const componentList = [
  { name: 'input', component: FormInput },
  { name: 'switch', component: FormSwitch },
  { name: 'date-picker', component: FormDatePicker },
  { name: 'time-picker', component: FormTimePicker },
  { name: 'slider', component: FormSlider },
  { name: 'time-select', component: FormTimeSelect },
  { name: 'transfer', component: FormTransfer },
  { name: 'tree', component: FormTree },
  { name: 'upload', component: FormUpload },
  { name: 'avatar', component: FormAvatar },
  { name: 'input-number', component: FormInputNumber },
  { name: 'select', component: FormSelect },
  { name: 'radio', component: FormRadio },
  { name: 'checkbox', component: FormCheckbox },
]

componentList.forEach((item) => {
  componentMap.set(item.name, item.component)
})

export function add(name, component) {
  componentMap.set(name, component)
}

export function del(name) {
  componentMap.delete(name)
}

export { componentMap }
